package cn.wolfcode.trip.base.service.impl;

import cn.wolfcode.trip.base.domain.HotelDetail;
import cn.wolfcode.trip.base.mapper.HotelDetailMapper;
import cn.wolfcode.trip.base.query.QueryObject;
import cn.wolfcode.trip.base.service.IHotelDetailService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class IHotelDetailServiceImpl implements IHotelDetailService {
    @Autowired
    private HotelDetailMapper hotelDetailMapper;

    public PageInfo<HotelDetail> query(QueryObject qo) {
        PageHelper.startPage(qo.getCurrentPage(),qo.getPageSize());
        return new PageInfo<>(hotelDetailMapper.selectForList(qo));
    }

    public void saveOrUpdate(HotelDetail entity) {
        if (entity.getId()==null) {
            hotelDetailMapper.insert(entity);
        }else{
            hotelDetailMapper.updateByPrimaryKey(entity);
        }

    }
}
